package com.ss.android.newmedia.e;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;

import com.ss.android.account.Spipe;
import com.ss.android.b.AdManager;
import com.ss.android.common.applog.AppLog;
import com.ss.android.newmedia.BatchActionService;
import com.ss.android.newmedia.NewMediaConstants;
import com.ss.android.newmedia.BaseAppData;
import com.ss.android.update.UpdateHelper;
import com.ss.android.update.m;

import java.util.Iterator;
import java.util.List;

public abstract class f {
    private static boolean f;

    static {
        f = false;
    }

    protected Activity a;
    private NotificationManager b;
    private boolean c;
    private BaseAppData d;
    private Handler e;

    public f(Activity arg2) {
        this.e = new Handler();
        this.a = arg2;
        this.b = (NotificationManager) arg2.getSystemService(Context.NOTIFICATION_SERVICE);
        this.d = BaseAppData.inst();
        this.c = false;
    }

    public static void c() {
        f = false;
    }

    public void a() {
        this.c = true;
        List v0 = ((ActivityManager) this.a.getSystemService(Context.ACTIVITY_SERVICE)).getRunningAppProcesses();
        if (v0 != null && !v0.isEmpty()) {
            Iterator v1 = v0.iterator();
            while (v1.hasNext()) {
                Object v0_1 = v1.next();
                if (((ActivityManager.RunningAppProcessInfo) v0_1).processName == null) {
                    continue;
                }

                if (!((ActivityManager.RunningAppProcessInfo) v0_1).processName.contains(":PluginProcess")) {
                    continue;
                }

                this.e.post(new h(((ActivityManager.RunningAppProcessInfo) v0_1)));
            }
        }
    }

    public final void b() {
        UpdateHelper v1;
        int v0 = 1;
        if (!this.c) {
            try {
                this.b.cancel(com.ss.android.article.browser.R.id.an);
                this.b.cancel(com.ss.android.article.browser.R.id.am);
            } catch (Exception v2) {
            }

            BaseAppData v3 = this.d;
            String v4 = v3.appContext.getChannel();
            String[] v5 = NewMediaConstants.aa;
            int v2_1 = 0;
            while (true) {
                if (v2_1 >= 4) {
                    if (v3.cw != 1) {
                        v0 = 0;
                    }
                    break;
                } else if (!v5[v2_1].equalsIgnoreCase(v4)) {
                    ++v2_1;
                    continue;
                } else {
                    v0 = 0;
                    break;
                }
            }


            if (v0 != 0) {
                this.d.k(this.a);
                v1 = UpdateHelper.getInstance();
                synchronized (v1) {
                    if (!v1.k) {
                        v1.v();
                        v1.k = true;
                    }

                    if (v1.m) {
                    } else {
                        new m(v1, "UpdateHelper-Thread").start();
                    }
                }
            }

            label_39:
            new Handler(Looper.getMainLooper()).postDelayed(new g(this), 2000);
            try {
                this.a.startService(new Intent(this.a, BatchActionService.class));
            } catch (Throwable v0_1) {
            }

            AdManager.getInstance(this.a).c = 0;
            Spipe.inst().b(this.a);
            AppLog.B();
        }

        return;
    }
}

